home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / Tcl-Tk 8.0 / Pre-installed version / tk8.0 / tests / scrollbar.test < prev    next >
Encoding:
Text File  |  1997-08-15  |  23.5 KB  |  666 lines  |  [TEXT/ALFA]

  1. # This file is a Tcl script to test out scrollbar widgets and
  2. # the "scrollbar" command of Tk.  It is organized in the standard
  3. # fashion for Tcl tests.
  4. #
  5. # Copyright (c) 1994 The Regents of the University of California.
  6. # Copyright (c) 1994-1997 Sun Microsystems, Inc.
  7. #
  8. # See the file "license.terms" for information on usage and redistribution
  9. # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  10. #
  11. # SCCS: @(#) scrollbar.test 1.33 97/08/13 17:37:19
  12.  
  13. if {[info procs test] != "test"} {
  14.     source defs
  15. }
  16.  
  17. foreach i [winfo children .] {
  18.     destroy $i
  19. }
  20. wm geometry . {}
  21. raise .
  22. update
  23.  
  24. proc scroll args {
  25.     global scrollInfo
  26.     set scrollInfo $args
  27. }
  28.  
  29. proc getTroughSize {w} {
  30.     global tcl_platform
  31.     if {$tcl_platform(platform) == "windows"} {
  32.     if [string match v* [$w cget -orient]] {
  33.         return [expr [winfo height $w] - 2*[testmetrics cyvscroll]]
  34.     } else {
  35.         return [expr [winfo width $w] - 2*[testmetrics cxhscroll]]
  36.     }        
  37.     } else {
  38.     if [string match v* [$w cget -orient]] {
  39.         return [expr [winfo height $w] \
  40.             - ([winfo width $w] \
  41.                    - [$w cget -highlightthickness] \
  42.                    - [$w cget -bd] + 1)*2]
  43.     } else {
  44.         return [expr [winfo width $w] \
  45.             - ([winfo height $w] \
  46.                    - [$w cget -highlightthickness] \
  47.                    - [$w cget -bd] + 1)*2]
  48.     }
  49.     }
  50. }
  51.  
  52. # XXX Note: this test file is woefully incomplete.  Right now there are
  53. # only bits and pieces of tests.  Please make this file more complete
  54. # as you fix bugs and add features.
  55.  
  56. foreach {width height} [wm minsize .] {
  57.     set height [expr ($height < 200) ? 200 : $height]
  58.     set width [expr ($width < 1) ? 1 : $width]
  59.  
  60. frame .f -height $height -width $width
  61. pack .f -side left
  62. scrollbar .s
  63. pack .s -side right -fill y
  64. update
  65. set i 1
  66. foreach test {
  67.     {-activebackground #ff0000 #ff0000 non-existent
  68.         {unknown color name "non-existent"}}
  69.     {-activerelief sunken sunken non-existent
  70.         {bad relief type "non-existent": must be flat, groove, raised, ridge, solid, or sunken}}
  71.     {-background #ff0000 #ff0000 non-existent
  72.         {unknown color name "non-existent"}}
  73.     {-bd 4 4 badValue {bad screen distance "badValue"}}
  74.     {-bg #ff0000 #ff0000 non-existent
  75.         {unknown color name "non-existent"}}
  76.     {-borderwidth 1.3 1 badValue {bad screen distance "badValue"}}
  77.     {-command "set x" {set x} {} {}}
  78.     {-elementborderwidth 4 4 badValue {bad screen distance "badValue"}}
  79.     {-cursor arrow arrow badValue {bad cursor spec "badValue"}}
  80.     {-highlightbackground #112233 #112233 ugly {unknown color name "ugly"}}
  81.     {-highlightcolor #123456 #123456 bogus {unknown color name "bogus"}}
  82.     {-highlightthickness 6 6 bogus {bad screen distance "bogus"}}
  83.     {-highlightthickness -2 0 {} {}}
  84.     {-jump true 1 silly {expected boolean value but got "silly"}}
  85.     {-orient horizontal horizontal badValue
  86.         {bad orientation "badValue": must be vertical or horizontal}}
  87.     {-orient horizontal horizontal bogus {bad orientation "bogus": must be vertical or horizontal}}
  88.     {-relief ridge ridge badValue {bad relief type "badValue": must be flat, groove, raised, ridge, solid, or sunken}}
  89.     {-repeatdelay 140 140 129.3 {expected integer but got "129.3"}}
  90.     {-repeatinterval 140 140 129.3 {expected integer but got "129.3"}}
  91.     {-takefocus "any string" "any string" {} {}}
  92.     {-trough #432 #432 lousy {unknown color name "lousy"}}
  93.     {-width 32 32 badValue {bad screen distance "badValue"}}
  94. } {
  95.     set name [lindex $test 0]
  96.     test scrollbar-1.1 {configuration options} {
  97.     .s configure $name [lindex $test 1]
  98.     lindex [.s configure $name] 4
  99.     } [lindex $test 2]
  100.     incr i
  101.     if {[lindex $test 3] != ""} {
  102.     test scrollbar-1.2 {configuration options} {
  103.         list [catch {.s configure $name [lindex $test 3]} msg] $msg
  104.     } [list 1 [lindex $test 4]]
  105.     }
  106.     .s configure $name [lindex [.s configure $name] 3]
  107.     incr i
  108. }
  109.  
  110. destroy .s
  111. test scrollbar-2.1 {Tk_ScrollbarCmd procedure} {
  112.     list [catch {scrollbar} msg] $msg
  113. } {1 {wrong # args: should be "scrollbar pathName ?options?"}}
  114. test scrollbar-2.2 {Tk_ScrollbarCmd procedure} {
  115.     list [catch {scrollbar gorp} msg] $msg
  116. } {1 {bad window path name "gorp"}}
  117. test scrollbar-2.3 {Tk_ScrollbarCmd procedure} {
  118.     scrollbar .s
  119.     set x "[winfo class .s] [info command .s]"
  120.     destroy .s
  121.     set x
  122. } {Scrollbar .s}
  123. test scrollbar-2.4 {Tk_ScrollbarCmd procedure} {
  124.     list [catch {scrollbar .s -gorp blah} msg] $msg [winfo exists .s] \
  125.         [info command .s]
  126. } {1 {unknown option "-gorp"} 0 {}}
  127. test scrollbar-2.5 {Tk_ScrollbarCmd procedure} {
  128.     set x [scrollbar .s]
  129.     destroy .s
  130.     set x
  131. } {.s}
  132.  
  133. scrollbar .s -orient vertical -command scroll -highlightthickness 2 -bd 2
  134. pack .s -side right -fill y
  135. update
  136. test scrollbar-3.1 {ScrollbarWidgetCmd procedure} {
  137.     list [catch {.s} msg] $msg
  138. } {1 {wrong # args: should be ".s option ?arg arg ...?"}}
  139. test scrollbar-3.2 {ScrollbarWidgetCmd procedure, "cget" option} {
  140.     list [catch {.s cget} msg] $msg
  141. } {1 {wrong # args: should be ".s cget option"}}
  142. test scrollbar-3.3 {ScrollbarWidgetCmd procedure, "cget" option} {
  143.     list [catch {.s cget -gorp} msg] $msg
  144. } {1 {unknown option "-gorp"}}
  145. test scrollbar-3.4 {ScrollbarWidgetCmd procedure, "activate" option} {
  146.     list [catch {.s activate a b} msg] $msg
  147. } {1 {wrong # args: should be ".s activate element"}}
  148. test scrollbar-3.5 {ScrollbarWidgetCmd procedure, "activate" option} {
  149.     .s activate arrow1
  150.     .s activate
  151. } {arrow1}
  152. test scrollbar-3.6 {ScrollbarWidgetCmd procedure, "activate" option} {
  153.     .s activate slider
  154.     .s activate
  155. } {slider}
  156. test scrollbar-3.7 {ScrollbarWidgetCmd procedure, "activate" option} {
  157.     .s activate arrow2
  158.     .s activate
  159. } {arrow2}
  160. test scrollbar-3.8 {ScrollbarWidgetCmd procedure, "activate" option} {
  161.     .s activate s
  162.     .s activate {}
  163.     .s activate
  164. } {}
  165. test scrollbar-3.9 {ScrollbarWidgetCmd procedure, "activate" option} {
  166.     list [catch {.s activate trough1} msg] $msg
  167. } {0 {}}
  168. test scrollbar-3.10 {ScrollbarWidgetCmd procedure, "cget" option} {
  169.     list [catch {.s cget -orient} msg] $msg
  170. } {0 vertical}
  171. scrollbar .s2
  172. test scrollbar-3.11 {ScrollbarWidgetCmd procedure, "cget" option} {pc} {
  173.     list [catch {.s2 cget -bd} msg] $msg
  174. } {0 0}
  175. test scrollbar-3.12 {ScrollbarWidgetCmd procedure, "cget" option} {!pc} {
  176.     list [catch {.s2 cget -bd} msg] $msg
  177. } {0 2}
  178. test scrollbar-3.13 {ScrollbarWidgetCmd procedure, "cget" option} {pc} {
  179.     list [catch {.s2 cget -highlightthickness} msg] $msg
  180. } {0 0}
  181. test scrollbar-3.14 {ScrollbarWidgetCmd procedure, "cget" option} {!pc} {
  182.     list [catch {.s2 cget -highlightthickness} msg] $msg
  183. } {0 1}
  184. destroy .s2
  185. test scrollbar-3.15 {ScrollbarWidgetCmd procedure, "configure" option} {
  186.     llength [.s configure]
  187. } {20}
  188. test scrollbar-3.16 {ScrollbarWidgetCmd procedure, "configure" option} {
  189.     list [catch {.s configure -bad} msg] $msg
  190. } {1 {unknown option "-bad"}}
  191. test scrollbar-3.17 {ScrollbarWidgetCmd procedure, "configure" option} {
  192.     .s configure -orient
  193. } {-orient orient Orient vertical vertical}
  194. test scrollbar-3.18 {ScrollbarWidgetCmd procedure, "configure" option} {
  195.     .s configure -orient horizontal
  196.     set x [.s cget -orient]
  197.     .s configure -orient vertical
  198.     set x
  199. } {horizontal}
  200. test scrollbar-3.19 {ScrollbarWidgetCmd procedure, "configure" option} {
  201.     list [catch {.s configure -bad worse} msg] $msg
  202. } {1 {unknown option "-bad"}}
  203. test scrollbar-3.20 {ScrollbarWidgetCmd procedure, "delta" option} {
  204.     list [catch {.s delta 24} msg] $msg
  205. } {1 {wrong # args: should be ".s delta xDelta yDelta"}}
  206. test scrollbar-3.21 {ScrollbarWidgetCmd procedure, "delta" option} {
  207.     list [catch {.s delta 24 35 42} msg] $msg
  208. } {1 {wrong # args: should be ".s delta xDelta yDelta"}}
  209. test scrollbar-3.22 {ScrollbarWidgetCmd procedure, "delta" option} {
  210.     list [catch {.s delta silly 24} msg] $msg
  211. } {1 {expected integer but got "silly"}}
  212. test scrollbar-3.23 {ScrollbarWidgetCmd procedure, "delta" option} {
  213.     list [catch {.s delta 18 xxyz} msg] $msg
  214. } {1 {expected integer but got "xxyz"}}
  215. test scrollbar-3.24 {ScrollbarWidgetCmd procedure, "delta" option} {
  216.     list [catch {.s delta 18 xxyz} msg] $msg
  217. } {1 {expected integer but got "xxyz"}}
  218. test scrollbar-3.25 {ScrollbarWidgetCmd procedure, "delta" option} {
  219.     .s delta 20 0
  220. } {0}
  221. test scrollbar-3.26 {ScrollbarWidgetCmd procedure, "delta" option} {
  222.     .s delta 0 20
  223. } [format %.6g [expr 20.0/([getTroughSize .s]-1)]]
  224. test scrollbar-3.27 {ScrollbarWidgetCmd procedure, "delta" option} {
  225.     .s delta 0 -20
  226. } [format %.6g [expr -20.0/([getTroughSize .s]-1)]]
  227. test scrollbar-3.28 {ScrollbarWidgetCmd procedure, "delta" option} {
  228.     toplevel .t -width 250 -height 100
  229.     wm geom .t +0+0
  230.     scrollbar .t.s -orient horizontal -borderwidth 2
  231.     place .t.s -width 201
  232.     update
  233.     set result [list [.t.s delta 0 20] \
  234.             [.t.s delta [expr [getTroughSize .t.s] - 1] 0]]
  235.     destroy .t
  236.     set result
  237. } {0 1}
  238. test scrollbar-3.29 {ScrollbarWidgetCmd procedure, "fraction" option} {
  239.     list [catch {.s fraction 24} msg] $msg
  240. } {1 {wrong # args: should be ".s fraction x y"}}
  241. test scrollbar-3.30 {ScrollbarWidgetCmd procedure, "fraction" option} {
  242.     list [catch {.s fraction 24 30 32} msg] $msg
  243. } {1 {wrong # args: should be ".s fraction x y"}}
  244. test scrollbar-3.31 {ScrollbarWidgetCmd procedure, "fraction" option} {
  245.     list [catch {.s fraction silly 24} msg] $msg
  246. } {1 {expected integer but got "silly"}}
  247. test scrollbar-3.32 {ScrollbarWidgetCmd procedure, "fraction" option} {
  248.     list [catch {.s fraction 24 bogus} msg] $msg
  249. } {1 {expected integer but got "bogus"}}
  250. test scrollbar-3.33 {ScrollbarWidgetCmd procedure, "fraction" option} {
  251.     .s fraction 0 0
  252. } {0}
  253. test scrollbar-3.34 {ScrollbarWidgetCmd procedure, "fraction" option} {
  254.     .s fraction 0 1000
  255. } {1}
  256. test scrollbar-3.35 {ScrollbarWidgetCmd procedure, "fraction" option} {
  257.     .s fraction 4 21
  258. } [format %.6g [expr (21.0 - ([winfo height .s] - [getTroughSize .s])/2.0) \
  259.        /([getTroughSize .s] - 1)]]
  260. test scrollbar-3.36 {ScrollbarWidgetCmd procedure, "fraction" option} {unixOnly} {
  261.     .s fraction 4 179
  262. } {1}
  263. test scrollbar-3.37 {ScrollbarWidgetCmd procedure, "fraction" option} {macOrPc} {
  264.     .s fraction 4 [expr 200 - [testmetrics cyvscroll .s]]
  265. } {1}
  266. test scrollbar-3.38 {ScrollbarWidgetCmd procedure, "fraction" option} {unixOnly} {
  267.     .s fraction 4 178
  268. } {0.993711}
  269. test scrollbar-3.39 {ScrollbarWidgetCmd procedure, "fraction" option} {pcOnly} {
  270.     expr [.s fraction 4 [expr 200 - [testmetrics cyvscroll .s] - 2]] \
  271.     == [format %g [expr (200.0 - [testmetrics cyvscroll .s]*2 - 2) \
  272.                / ($height - 1 - [testmetrics cyvscroll .s]*2)]]
  273. } 1
  274. test scrollbar-3.40 {ScrollbarWidgetCmd procedure, "fraction" option} {macOnly} {
  275.     .s fraction 4 178
  276. } {0.97006}
  277.  
  278. toplevel .t -width 250 -height 100
  279. wm geom .t +0+0
  280. scrollbar .t.s -orient horizontal -borderwidth 2
  281. place .t.s -width 201
  282. update
  283.  
  284. test scrollbar-3.41 {ScrollbarWidgetCmd procedure, "fraction" option} {
  285.     .t.s fraction 100 0
  286. } {0.5}
  287. if {$tcl_platform(platform) == "windows"} {
  288.     place configure .t.s -width [expr 2*[testmetrics cxhscroll]+1]
  289. } else {
  290.     place configure .t.s -width [expr [winfo reqwidth .t.s] - 4]
  291. }
  292. update
  293. test scrollbar-3.42 {ScrollbarWidgetCmd procedure, "fraction" option} {
  294.     .t.s fraction 100 0
  295. } {0}
  296. destroy .t
  297. test scrollbar-3.43 {ScrollbarWidgetCmd procedure, "get" option} {
  298.     list [catch {.s get a} msg] $msg
  299. } {1 {wrong # args: should be ".s get"}}
  300. test scrollbar-3.44 {ScrollbarWidgetCmd procedure, "get" option} {
  301.     .s set 100 10 13 14
  302.     .s get
  303. } {100 10 13 14}
  304. test scrollbar-3.45 {ScrollbarWidgetCmd procedure, "get" option} {
  305.     .s set 0.6 0.8
  306.     set result {}
  307.     foreach element [.s get] {
  308.     lappend result [format %.1f $element]
  309.     }
  310.     set result
  311. } {0.6 0.8}
  312. test scrollbar-3.46 {ScrollbarWidgetCmd procedure, "identify" option} {
  313.     list [catch {.s identify 0} msg] $msg
  314. } {1 {wrong # args: should be ".s identify x y"}}
  315. test scrollbar-3.47 {ScrollbarWidgetCmd procedure, "identify" option} {
  316.     list [catch {.s identify 0 0 1} msg] $msg
  317. } {1 {wrong # args: should be ".s identify x y"}}
  318. test scrollbar-3.48 {ScrollbarWidgetCmd procedure, "identify" option} {
  319.     list [catch {.s identify bogus 2} msg] $msg
  320. } {1 {expected integer but got "bogus"}}
  321. test scrollbar-3.49 {ScrollbarWidgetCmd procedure, "identify" option} {
  322.     list [catch {.s identify -1 bogus} msg] $msg
  323. } {1 {expected integer but got "bogus"}}
  324. test scrollbar-3.50 {ScrollbarWidgetCmd procedure, "identify" option} {
  325.     .s identify 5 5
  326. } {arrow1}
  327. test scrollbar-3.51 {ScrollbarWidgetCmd procedure, "identify" option} {
  328.     .s identify 5 35
  329. } {trough1}
  330. test scrollbar-3.52 {ScrollbarWidgetCmd procedure, "identify" option} {
  331.     .s set .3 .6
  332.     .s identify 5 80
  333. } {slider}
  334. test scrollbar-3.53 {ScrollbarWidgetCmd procedure, "identify" option} {
  335.     .s identify 5 145
  336. } {trough2}
  337. test scrollbar-3.54 {ScrollbarWidgetCmd procedure, "identify" option} {unixOrPc} {
  338.     .s identify 5 195
  339. } {arrow2}
  340. test scrollbar-3.55 {ScrollbarWidgetCmd procedure, "identify" option} {macOnly} {
  341.     .s identify 5 195
  342. } {}
  343. test scrollbar-3.56 {ScrollbarWidgetCmd procedure, "identify" option} {unixOnly} {
  344.     .s identify 0 0
  345. } {}
  346. test scrollbar-3.57 {ScrollbarWidgetCmd procedure, "set" option} {
  347.     list [catch {.s set abc def} msg] $msg
  348. } {1 {expected floating-point number but got "abc"}}
  349. test scrollbar-3.58 {ScrollbarWidgetCmd procedure, "set" option} {
  350.     list [catch {.s set 0.6 def} msg] $msg
  351. } {1 {expected floating-point number but got "def"}}
  352. test scrollbar-3.59 {ScrollbarWidgetCmd procedure, "set" option} {
  353.     .s set -.2 .3
  354.     set result {}
  355.     foreach element [.s get] {
  356.     lappend result [format %.1f $element]
  357.     }
  358.     set result
  359. } {0.0 0.3}
  360. test scrollbar-3.60 {ScrollbarWidgetCmd procedure, "set" option} {
  361.     .s set 1.1 .4 
  362.     .s get
  363. } {1.0 1.0}
  364. test scrollbar-3.61 {ScrollbarWidgetCmd procedure, "set" option} {
  365.     .s set .5 -.3 
  366.     .s get
  367. } {0.5 0.5}
  368. test scrollbar-3.62 {ScrollbarWidgetCmd procedure, "set" option} {
  369.     .s set .5 87 
  370.     .s get
  371. } {0.5 1.0}
  372. test scrollbar-3.63 {ScrollbarWidgetCmd procedure, "set" option} {
  373.     .s set .4 .3
  374.     set result {}
  375.     foreach element [.s get] {
  376.     lappend result [format %.1f $element]
  377.     }
  378.     set result
  379. } {0.4 0.4}
  380. test scrollbar-3.64 {ScrollbarWidgetCmd procedure, "set" option} {
  381.     list [catch {.s set abc def ghi jkl} msg] $msg
  382. } {1 {expected integer but got "abc"}}
  383. test scrollbar-3.65 {ScrollbarWidgetCmd procedure, "set" option} {
  384.     list [catch {.s set 1 def ghi jkl} msg] $msg
  385. } {1 {expected integer but got "def"}}
  386. test scrollbar-3.66 {ScrollbarWidgetCmd procedure, "set" option} {
  387.     list [catch {.s set 1 2 ghi jkl} msg] $msg
  388. } {1 {expected integer but got "ghi"}}
  389. test scrollbar-3.67 {ScrollbarWidgetCmd procedure, "set" option} {
  390.     list [catch {.s set 1 2 3 jkl} msg] $msg
  391. } {1 {expected integer but got "jkl"}}
  392. test scrollbar-3.68 {ScrollbarWidgetCmd procedure, "set" option} {
  393.     .s set -10 50 20 30 
  394.     .s get
  395. } {0 50 0 0}
  396. test scrollbar-3.69 {ScrollbarWidgetCmd procedure, "set" option} {
  397.     .s set 100 -10 20 30 
  398.     .s get
  399. } {100 0 20 30}
  400. test scrollbar-3.70 {ScrollbarWidgetCmd procedure, "set" option} {
  401.     .s set 100 50 30 20 
  402.     .s get
  403. } {100 50 30 30}
  404. test scrollbar-3.71 {ScrollbarWidgetCmd procedure, "set" option} {
  405.     list [catch {.s set 1 2 3} msg] $msg
  406. } {1 {wrong # args: should be ".s set firstFraction lastFraction" or ".s set totalUnits windowUnits firstUnit lastUnit"}}
  407. test scrollbar-3.72 {ScrollbarWidgetCmd procedure, "set" option} {
  408.     list [catch {.s set 1 2 3 4 5} msg] $msg
  409. } {1 {wrong # args: should be ".s set firstFraction lastFraction" or ".s set totalUnits windowUnits firstUnit lastUnit"}}
  410. test scrollbar-3.73 {ScrollbarWidgetCmd procedure} {
  411.     list [catch {.s bogus} msg] $msg
  412. } {1 {bad option "bogus": must be activate, cget, configure, delta, fraction, get, identify, or set}}
  413. test scrollbar-3.74 {ScrollbarWidgetCmd procedure} {
  414.     list [catch {.s c} msg] $msg
  415. } {1 {bad option "c": must be activate, cget, configure, delta, fraction, get, identify, or set}}
  416.  
  417. test scrollbar-4.1 {ScrollbarEventProc procedure} {
  418.     catch {destroy .s1}
  419.     scrollbar .s1 -bg #543210
  420.     rename .s1 .s2
  421.     set x {}
  422.     lappend x [winfo exists .s1]
  423.     lappend x [.s2 cget -bg]
  424.     destroy .s1
  425.     lappend x [info command .s?] [winfo exists .s1] [winfo exists .s2]
  426. } {1 #543210 {} 0 0}
  427.  
  428. test scrollbar-5.1 {ScrollbarCmdDeletedProc procedure} {
  429.     catch {destroy .s1}
  430.     scrollbar .s1
  431.     rename .s1 {}
  432.     list [info command .s?] [winfo exists .s1]
  433. } {{} 0}
  434.  
  435. catch {destroy .s}
  436. scrollbar .s -orient vertical -relief sunken -bd 2 -highlightthickness 2
  437. pack .s -side left -fill y
  438. .s set .2 .4
  439. update
  440. test scrollbar-6.1 {ScrollbarPosition procedure} {unixOnly} {
  441.     .s identify 8 3
  442. } {}
  443. test scrollbar-6.2 {ScrollbarPosition procedure} {macOnly} {
  444.     .s identify 8 3
  445. } {arrow1}
  446. test scrollbar-6.3 {ScrollbarPosition procedure} {macOrUnix} {
  447.     .s identify 8 196
  448. } {}
  449. test scrollbar-6.4 {ScrollbarPosition procedure} {unixOnly} {
  450.     .s identify 3 100
  451. } {}
  452. test scrollbar-6.5 {ScrollbarPosition procedure} {macOnly} {
  453.     .s identify 3 100
  454. } {trough2}
  455. test scrollbar-6.6 {ScrollbarPosition procedure} {macOrUnix} {
  456.     .s identify 19 100
  457. } {}
  458. test scrollbar-6.7 {ScrollbarPosition procedure} {
  459.     .s identify [expr [winfo width .s] / 2] -1
  460. } {}
  461. test scrollbar-6.8 {ScrollbarPosition procedure} {
  462.     .s identify [expr [winfo width .s] / 2] [expr [winfo height .s]]
  463. } {}
  464. test scrollbar-6.9 {ScrollbarPosition procedure} {
  465.     .s identify -1 [expr [winfo height .s] / 2]
  466. } {}
  467. test scrollbar-6.10 {ScrollbarPosition procedure} {
  468.     .s identify [winfo width .s] [expr [winfo height .s] / 2]
  469. } {}
  470.  
  471. test scrollbar-6.11 {ScrollbarPosition procedure} {macOrUnix} {
  472.     .s identify 8 4
  473. } {arrow1}
  474. test scrollbar-6.12 {ScrollbarPosition procedure} {unixOnly} {
  475.     .s identify 8 19
  476. } {arrow1}
  477. test scrollbar-6.13 {ScrollbarPosition procedure} {macOnly} {
  478.     .s identify 8 19
  479. } {trough1}
  480. test scrollbar-6.14 {ScrollbarPosition procedure} {pcOnly} {
  481.     .s identify [expr [winfo width .s] / 2] 0 
  482. } {arrow1}
  483. test scrollbar-6.15 {ScrollbarPosition procedure} {pcOnly} {
  484.     .s identify [expr [winfo width .s] / 2] [expr [testmetrics cyvscroll] - 1]
  485. } {arrow1}
  486.  
  487. test scrollbar-6.16 {ScrollbarPosition procedure} {macOrUnix} {
  488.     .s identify 8 20
  489. } {trough1}
  490. test scrollbar-6.17 {ScrollbarPosition procedure} {macOrUnix nonPortable} {
  491.     # Don't know why this is non-portable, but it doesn't work on
  492.     # some platforms.
  493.     .s identify 8 51
  494. } {trough1}
  495. test scrollbar-6.18 {ScrollbarPosition procedure} {pcOnly} {
  496.     .s identify [expr [winfo width .s] / 2] [testmetrics cyvscroll]
  497. } {trough1}
  498. test scrollbar-6.19 {ScrollbarPosition procedure} {pcOnly} {
  499.     .s identify [expr [winfo width .s] / 2] [expr int(.2 / [.s delta 0 1]) \
  500.                         + [testmetrics cyvscroll] - 1]
  501. } {trough1}
  502.  
  503. test scrollbar-6.20 {ScrollbarPosition procedure} {macOrUnix} {
  504.     .s identify 8 52
  505. } {slider}
  506. test scrollbar-6.21 {ScrollbarPosition procedure} {macOrUnix nonPortable} {
  507.     # Don't know why this is non-portable, but it doesn't work on
  508.     # some platforms.
  509.     .s identify 8 83
  510. } {slider}
  511. test scrollbar-6.22 {ScrollbarPosition procedure} {pcOnly} {
  512.     .s identify [expr [winfo width .s] / 2] [expr int(.2 / [.s delta 0 1]) \
  513.                         + [testmetrics cyvscroll]]
  514. } {slider}
  515. test scrollbar-6.23 {ScrollbarPosition procedure} {pcOnly} {
  516.     .s identify [expr [winfo width .s] / 2] [expr int(.4 / [.s delta 0 1]) \
  517.                          + [testmetrics cyvscroll] - 1]
  518. } {slider}
  519.  
  520. test scrollbar-6.24 {ScrollbarPosition procedure} {macOrUnix} {
  521.     .s identify 8 84
  522. } {trough2}
  523. test scrollbar-6.25 {ScrollbarPosition procedure} {unixOnly} {
  524.     .s identify 8 179
  525. } {trough2}
  526. test scrollbar-6.26 {ScrollbarPosition procedure} {macOnly} {
  527.     .s identify 8 179
  528. } {arrow2}
  529. test scrollbar-6.27 {ScrollbarPosition procedure} {pcOnly} {
  530.     .s identify [expr [winfo width .s] / 2] [expr int(.4 / [.s delta 0 1]) \
  531.                          + [testmetrics cyvscroll]]
  532. } {trough2}
  533. test scrollbar-6.28 {ScrollbarPosition procedure} {pcOnly} {
  534.     .s identify [expr [winfo width .s] / 2] [expr [winfo height .s] \
  535.                          - [testmetrics cyvscroll] - 1]
  536. } {trough2}
  537.  
  538. test scrollbar-6.29 {ScrollbarPosition procedure} {macOrUnix} {
  539.     .s identify 8 180
  540. } {arrow2}
  541. test scrollbar-6.30 {ScrollbarPosition procedure} {unixOnly} {
  542.     .s identify 8 195
  543. } {arrow2}
  544. test scrollbar-6.31 {ScrollbarPosition procedure} {macOnly} {
  545.     .s identify 8 195
  546. } {}
  547. test scrollbar-6.32 {ScrollbarPosition procedure} {pcOnly} {
  548.     .s identify [expr [winfo width .s] / 2]  [expr [winfo height .s] \
  549.                           - [testmetrics cyvscroll]]
  550. } {arrow2}
  551. test scrollbar-6.33 {ScrollbarPosition procedure} {pcOnly} {
  552.     .s identify [expr [winfo width .s] / 2] [expr [winfo height .s] - 1]
  553. } {arrow2}
  554.  
  555. test scrollbar-6.34 {ScrollbarPosition procedure} {macOrUnix} {
  556.     .s identify 4 100
  557. } {trough2}
  558. test scrollbar-6.35 {ScrollbarPosition procedure} {unixOnly} {
  559.     .s identify 18 100
  560. } {trough2}
  561. test scrollbar-6.36 {ScrollbarPosition procedure} {macOnly} {
  562.     .s identify 18 100
  563. } {}
  564. test scrollbar-6.37 {ScrollbarPosition procedure} {pcOnly} {
  565.     .s identify 0 100
  566. } {trough2}
  567. test scrollbar-6.38 {ScrollbarPosition procedure} {pcOnly} {
  568.     .s identify [expr [winfo width .s] - 1] 100
  569. } {trough2}
  570.  
  571. catch {destroy .t}
  572. toplevel .t -width 250 -height 150
  573. wm geometry .t +0+0
  574. scrollbar .t.s -orient horizontal -relief sunken -bd 2 -highlightthickness 2
  575. place .t.s -width 200
  576. .t.s set .2 .4
  577. update
  578. test scrollbar-6.39 {ScrollbarPosition procedure} {macOrUnix} {
  579.     .t.s identify 4 8
  580. } {arrow1}
  581. test scrollbar-6.40 {ScrollbarPosition procedure} {pcOnly} {
  582.     .t.s identify 0 [expr [winfo height .t.s] / 2]
  583. } {arrow1}
  584. test scrollbar-6.41 {ScrollbarPosition procedure} {unixOnly} {
  585.     .t.s identify 82 8
  586. } {slider}
  587. test scrollbar-6.42 {ScrollbarPosition procedure} {macOnly} {
  588.     .t.s identify 82 8
  589. } {}
  590. test scrollbar-6.43 {ScrollbarPosition procedure} {pcOnly} {
  591.     .t.s identify [expr int(.4 / [.t.s delta 1 0]) + [testmetrics cxhscroll] \
  592.                - 1] [expr [winfo height .t.s] / 2] 
  593. } {slider}
  594. test scrollbar-6.44 {ScrollbarPosition procedure} {unixOnly} {
  595.     .t.s identify 100 18
  596. } {trough2}
  597. test scrollbar-6.45 {ScrollbarPosition procedure} {macOnly} {
  598.     .t.s identify 100 18
  599. } {}
  600. test scrollbar-6.46 {ScrollbarPosition procedure} {pcOnly} {
  601.     .t.s identify 100 [expr [winfo height .t.s] - 1]
  602. } {trough2}
  603.  
  604. test scrollbar-7.1 {EventuallyRedraw} {
  605.     .s configure -orient horizontal
  606.     update
  607.     set result [.s cget -orient]
  608.     .s configure -orient vertical
  609.     update
  610.     lappend result [.s cget -orient]
  611. } {horizontal vertical}
  612.  
  613. catch {destroy .t}
  614. toplevel .t
  615. wm geometry .t +0+0
  616. test scrollbar-8.1 {TkScrollbarEventProc: recursive deletion} {
  617.     proc doit {args} { destroy .t.f }
  618.     proc bgerror {args} {}
  619.     frame .t.f
  620.     scrollbar .t.f.s -command doit
  621.     pack .t.f -fill both -expand 1
  622.     pack .t.f.s -fill y -expand 1 -side right
  623.     wm geometry .t 100x100
  624.     .t.f.s set 0 .5
  625.     update
  626.     set result [winfo exists .t.f.s]
  627.     event generate .t.f.s <ButtonPress> -button 1 -x [expr [winfo width .t.f.s] / 2] -y 5
  628.     update
  629.     lappend result [winfo exists .t.f.s] [winfo exists .t.f]
  630.     rename bgerror {}
  631.     set result
  632. } {1 0 0}
  633. test scrollbar-8.2 {TkScrollbarEventProc: recursive deletion} {
  634.     proc doit {args} { destroy .t.f.s }
  635.     proc bgerror {args} {}
  636.     frame .t.f
  637.     scrollbar .t.f.s -command doit
  638.     pack .t.f -fill both -expand 1
  639.     pack .t.f.s -fill y -expand 1 -side right
  640.     wm geometry .t 100x100
  641.     .t.f.s set 0 .5
  642.     update
  643.     set result [winfo exists .t.f.s]
  644.     event generate .t.f.s <ButtonPress> -button 1 -x [expr [winfo width .t.f.s] / 2] -y 5
  645.     update
  646.     lappend result [winfo exists .t.f.s] [winfo exists .t.f]
  647.     rename bgerror {}
  648.     set result
  649. } {1 0 1}
  650.  
  651. set l [interp hidden]
  652. eval destroy [winfo children .]
  653.  
  654. test scrollbar-9.1 {scrollbar widget vs hidden commands} {
  655.     catch {destroy .s}
  656.     scrollbar .s
  657.     interp hide {} .s
  658.     destroy .s
  659.     list [winfo children .] [interp hidden]
  660. } [list {} $l]
  661.  
  662. catch {destroy .s}
  663. catch {destroy .t}
  664. concat {}
  665.